package com.ysj.demo.accompanynetwork.mvp.model;

import com.google.gson.Gson;
import com.ysj.demo.accompanynetwork.ApiServiceUntil;
import com.ysj.demo.accompanynetwork.bean.BonuspointSearchModel;
import com.ysj.demo.accompanynetwork.bean.PartnerConsumeRecord;
import com.ysj.demo.accompanynetwork.bean.RestRsp;
import com.ysj.demo.accompanynetwork.mvp.common.OnCommonListener;
import com.ysj.demo.accompanynetwork.service.bean.page.Page;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class BounsPointModel {

    private Gson gson = new Gson();
    private OnCommonListener onCommonListener;

    public void search(BonuspointSearchModel searchModel){
        Call<RestRsp<Page<PartnerConsumeRecord>>> call = ApiServiceUntil.getInstance().getBounsPointsService().search(searchModel);
        call.enqueue(new Callback<RestRsp<Page<PartnerConsumeRecord>>>() {
            @Override
            public void onResponse(Call<RestRsp<Page<PartnerConsumeRecord>>> call, Response<RestRsp<Page<PartnerConsumeRecord>>> response) {
                onCommonListener.onSuccessListener(response.body());
            }

            @Override
            public void onFailure(Call<RestRsp<Page<PartnerConsumeRecord>>> call, Throwable t) {
                onCommonListener.onSuccessListener(t);
            }
        });
    }

    public void userPoint(String userid){
        BonuspointSearchModel searchModel = new BonuspointSearchModel();
        searchModel.setUserid(userid);
        Call<RestRsp> call = ApiServiceUntil.getInstance().getBounsPointsService().userPoint(searchModel);
        call.enqueue(new Callback<RestRsp>() {
            @Override
            public void onResponse(Call<RestRsp> call, Response<RestRsp> response) {
                onCommonListener.onSuccessListener(response.body());
            }

            @Override
            public void onFailure(Call<RestRsp> call, Throwable t) {
                onCommonListener.onSuccessListener(t);
            }
        });
    }

}
